const util = require('../../utils/util.js');
const api = require('../../config/api.js');

//获取应用实例
const app = getApp();
Page({
  data: {
    latitude:'',
    longitude:'',
    markers: [{
      // iconPath: "../../static/images/positon.png",
      id: 0,
      latitude: 28.099994,
      longitude: 113.324520,
      width: 50,
      height: 50
    }],
   /*  polyline: [{
      points: [{
        longitude: 113.3245211,
        latitude: 23.10229
      }, {
        longitude: 113.324520,
        latitude: 23.21229
      }],
      color:"#FF0000DD",
      width: 2,
      dottedLine: true
    }], */
   /*  controls: [{
      id: 1,
      // iconPath: '../../static/images/positon.png',
      position: {
        left: 0,
        top: 300 - 50,
        width: 50,
        height: 50
      },
      clickable: true
    }] */
  },
  onShow: function() {
    const postion = wx.getStorageSync('postion')
    this.setData({
      latitude: postion.latitude,
      longitude: postion.longitude
    });

    var that=this
    util.request(api.searchNearBy, {
      location: this.data.latitude +','+ this.data.longitude
    }).then(function(res) {
      if (res.errno === 0) { 
        var tmpData=res.data.result.data
        tmpData.forEach(element => {
          element.latitude=element.location.lat
          element.longitude=element.location.lng
        });
        that.setData({
          markers:  res.data.result.data
        });
        
      }
      wx.hideLoading();
        console.log( that.footprintList)
    });
  },
  regionchange(e) {
    console.log(e.type)
  },
  markertap(e) {
    console.log(e.detail.markerId)
  },
  controltap(e) {
    console.log(e.detail.controlId)
  }
})